import cv2

#打开图像
img = cv2.imread(r'H:\Opencv-SimpleTest\lena.jpg')  #r取消转义
cv2.imshow('hello world!', img)
cv2.waitKey()
cv2.destroyAllWindows()




import cv2 as cv

#HSV颜色模型转换
#filename = r'H:\Opencv-SimpleTest\opencv-logo-white.png'
filename = r'H:\Opencv-SimpleTest\baboon.jpg'
img = cv.imread(filename)
gray = cv.cvtColor(img,cv.COLOR_BGR2GRAY)

cv.imshow("source image", img)
cv.imshow("gray", gray)
#cv.waitKey()

hsv = cv.cvtColor(img,cv.COLOR_BGR2HSV)

cv.imshow("Hue", hsv[:, :, 0])
cv.imshow("Saturation", hsv[:, :, 1])
cv.imshow("Value", hsv[:, :, 2])
#cv.waitKey()

cv.imshow("blue", img[:, :, 0])
cv.imshow("grenn", img[:, :, 1])
cv.imshow("red", img[:, :, 2])

cv.waitKey()
cv.destroyAllWindows()
